Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for publishing #35

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

armaniferrante
Copy link

@armaniferrante armaniferrante commented Aug 14, 2021

Adds an Anchor.toml to publish a deterministic build to https://anchor.projectserum.com by running in the root of the repo

anchor publish spl_token_lending

Because this is a monorepo, in order to build any of the programs, all of them must be present. I've modified the Cargo.toml so that this isn't necessary. When you upload to the registry, only the code required to build the contract will be uploaded and displayed, instead of the entire repo.

You probably shouldn't merge the Cargo.toml changes, but you can refer to them for when you're ready to publish.

wallet = "~/.config/solana/id.json"

[programs.mainnet]
spl_token_lending = "<program-id-here>"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When publishing, make sure to enter the program ID you want to use here.

@nope-finance
Copy link
Member

ah, yeah usually we cd to the specific dir and build there. would it not make more sense to just add the Anchor.toml to the token-lending/program dir?

@armaniferrante
Copy link
Author

ah, yeah usually we cd to the specific dir and build there. would it not make more sense to just add the Anchor.toml to the token-lending/program dir?

The tricky part is that the root level workspace Cargo.toml references all the various programs in the monorepo. So the entire workspace needs to be uploaded to the registry to build, even if you cd into the relevant subdirectory. So we're left with a couple options.

  • Upload the entire workspace to the registry (downside is that there will be a lot of irrelevant code for users).
  • Remove all code not relevant to the program (my preferred choice but the downside here is that it will probably make it more painful to integrate upstream changes) and move the Cargo.lock into token-lending/program.
  • Change the Cargo.toml whenever you upload to the registry to remove all code that isn't used. Bit of a hack but a lazy compromise considering the first two points. This is what the changes here do.

Any other ideas?

@nope-finance
Copy link
Member

ahh makes sense, i guess the other way would be turning it into a subrepo but probably not worth the effort
Yeah will do option 3 for now and do 2 shortly (want to be careful with some tests), we need to manually do upstream changes anyway since we diverged significantly (solana didn't want some of our changes relating to backup oracles).

@nope-finance
Copy link
Member

nope-finance commented Aug 14, 2021

# anchor publish spl_token_lending
Publishing will make your code public. Are you sure? Enter (yes)/no:
yes
Using image "projectserum/build:v0.13.2"
Run docker image
Cleaning up the docker target directory
Error: Docker rm docker-target failed: No such file or directory (os error 2)

does this require docker to use?

@armaniferrante
Copy link
Author

Cleaning up the docker target directory

Yes. cargo build-bpf will insert machine specific data into the binary (like filepaths) so the program must be built in docker for it to be verifiable.

@nope-finance
Copy link
Member

ah, yeah to have the builds consistent. im on wsl1 (can't use docker) so ill have to get someone else to run this later 🤦 my bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants